using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SceneResolution : MonoBehaviour
{
    private Vector2 curSize;
    private Vector2 lastSize;
    [SerializeField] Vector2 origion = new Vector2(1440, 1080);

    void Start()
    {
        //origion = new Vector2(1440, 1080);
        //curSize = lastSize = new Vector2(Screen.width, Screen.height);
        //SetResolution();
    }

    private void Update()
    {
        curSize.x = Screen.width;
        curSize.y = Screen.height;
        if (curSize.x != lastSize.x || curSize.y != lastSize.y)
        {
            SetResolution();
        }
    }


    void SetResolution()
    {
        Vector2 endSize = Util.AutoSize(origion, curSize);

        Debug.Log("SetResolution:" + origion + " " + lastSize + " " + curSize + " " + endSize);

        Screen.SetResolution((int)endSize.x, (int)endSize.y, true);
         
        lastSize = endSize;
    }
}
